Custom hooks are used to encapsulate and reuse stateful logic across multiple components. To create a custom hook, follow these steps:
Start with 'use': prefix the Name of the custom hook with 'use' to make it clear that it's a hook.
Reuse Existing Hooks: Custom hooks can internally use built-in hooks to achieve functionality.
Change the document title based on rendered values
Get or set values from local storage
Run analytics events
Show some greetings based on the time of day
Focus on a form field after the load